
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="common/css_js.jsp"/>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div class="container">

    <h3 class="mt-3 mb-3">个人信息</h3>

    <form  onsubmit="return false"><%--action后什么不写提交当前的Servlet，doPost接收--%>
        <div class="form-group">
            <label for="customerId">ID:</label>
            <%--readonly属性可以让input标签不可选，type="hidden"可以隐藏input框可以防止ID被修改。--%>
            <input  class="form-control" id="customerId"  value="${loginUser.c_id}" readonly="readonly">
        </div>
        <div class="form-group">
            <label for="customerName">姓名</label>
            <input type="text" class="form-control" id="customerName"  value="${loginUser.c_name}">
        </div>
        <div class="form-group">
            <label for="sex">性别</label>
            <input type="text" class="form-control" id="sex"  value="${loginUser.c_sex}">
        </div>
        <div class="form-group">
            <label for="username">账号</label>
            <input type="text" class="form-control" id="username"  value="${loginUser.c_username}" readonly="readonly">
        </div>
        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" class="form-control" id="password"  value="${loginUser.c_password}">
        </div>
        <div class="form-group">
            <label for="phone">电话</label>
            <input type="text" class="form-control" id="phone"  value="${loginUser.c_phone}">
        </div>
        <div class="form-group">
            <label for="address">地址</label>
            <input type="text" class="form-control" id="address"  value="${loginUser.c_address}">
        </div>
        <button type="button" class="btn btn-secondary" onclick="edit()">确定修改</button>
    </form>
</div>
<br>
</body>
<script>
    function edit() {
        var customer = {"c_id":$("#customerId").val(),"c_name":$("#customerName").val(),"c_sex":$("#sex").val(),
                    "c_username":$("#username").val(),"c_password":$("#password").val(),"c_phone":$("#phone").val(),"c_address":$("#address").val()}
        $.ajax({
            url:"personalEdit",
            method:"post",
            contentType:"application/json",
            data: JSON.stringify(customer),
            success:function (data) {
                if (data=="ok"){
                    alert("修改成功")
                    parent.location.reload();
                    layer_close();
                }else {
                    alert("修改失败")
                }
            }
        })
    }
</script>
</html>
